# base project definitions
# requirements:
#  1. TEMPLATE defined
#  2. DEV_ROOT defined

PROJECT_FILE_NAME = $$replace(_PRO_FILE_, $$_PRO_FILE_PWD_/, )
PROJECT_NAME      = $$replace(PROJECT_FILE_NAME, .pro, )

unix {
   contains(TEMPLATE, app): TARGET=$$PROJECT_NAME".exe"
   contains(TEMPLATE, lib): CONFIG += plugin shared
}

#paths
#INCLUDE_PATH = $$DEV_ROOT/Build/$(PROJECTID)/Include # attach megapomoika

##########################
# debug/release management
CONFIG(debug,debug|release){
    BUILD_PATH = $$DEV_ROOT/bin/debug
    CONFIG    += debug
    CONFIG    -= release

    PATH_SUFFIX = debug

    unix:QMAKE_CXXFLAGS += -O0

    message("Debug Configuration")
} else {
    BUILD_PATH = $$DEV_ROOT/bin/release
    CONFIG    += release
    CONFIG    -= debug

    RELEASE_CFG = True
    PATH_SUFFIX = release

    unix:QMAKE_CXXFLAGS += -O2

    DEFINES *= NDEBUG

    message("Release Configuration")
}

MISC_PATH = $$BUILD_PATH/$$PROJECT_NAME

#############
# build paths
OUT_PWD     = $$MISC_PATH
DESTDIR     = $$BUILD_PATH
OBJECTS_DIR = $$MISC_PATH
MOC_DIR     = $$MISC_PATH
UI_DIR      = $$MISC_PATH
RCC_DIR     = $$MISC_PATH

#############
# include paths
INCLUDEPATH += ./
INCLUDEPATH += $$INCLUDE_PATH
INCLUDEPATH += $$_PRO_FILE_PWD_

#############
# lib paths
#LIBS += -L$$DEV_ROOT/Build/$(PROJECTID)/Lib
LIBS += -L$$BUILD_PATH

######################
# common configuration
#CONFIG *= precompile_header
CONFIG -= qt
#CONFIG -= qt_no_framework

######################
# use this flag to turn on VLD in debug
#DEFINES += VLD_CHECK

###################
# compilation flags
unix{
    QMAKE_CXXFLAGS += -std=c++11
#    QMAKE_CXXFLAGS += -static-libstdc++
#    QMAKE_CXXFLAGS += -D__forceinline=inline
#    QMAKE_CXXFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden
#    QMAKE_CXXFLAGS += -Wall -Wno-ignored-qualifiers -Wno-attributes
    QMAKE_CXXFLAGS += -Wall
    QMAKE_CXXFLAGS += -g2
#    QMAKE_CXXFLAGS += -frounding-math #is needed by CGAL
#    QMAKE_CXXFLAGS += -Wl,--no-as-needed
#    QMAKE_CXXFLAGS += -Wl,--copy-dt-needed-entries
#    QMAKE_CXXFLAGS += -Wunknown-pragmas

    QMAKE_RPATHDIR += $$BUILD_PATH
    QMAKE_RPATHDIR += .
}
